package com.hsgene.order.condition;

import com.hsgene.common.util.support.OrderField;

import java.util.stream.Stream;

/**
 * 花生仁订单查询排序条件
 *
 * @author wangbing
 * @version 1.0, 2018/9/18
 */
public enum GeneticTestingOrderField implements OrderField {

    /**
     * 创建时间
     */
    CREATE_DATE_TIME("create_date_time"),

    /**
     * 更新时间
     */
    UPDATE_DATE_TIME("update_date_time"),

    /**
     * 价位（总价）
     */
    TOTAL_CHARGES("total_charges"),

    /**
     * 积分
     */
    TOTAL_COMMISSION("total_commission"),

    /**
     * 超期套餐个数
     */
    POSTPONE_PACKAGE_COUNT("postpone_package_count");

    private final String value;

    GeneticTestingOrderField(String value) {
        this.value = value;
    }

    public static GeneticTestingOrderField parseIntOrderBy(int orderBy) {
        return orderBy == 0 ? CREATE_DATE_TIME : UPDATE_DATE_TIME;
    }

    public static GeneticTestingOrderField getInstance() {
        return values()[0];
    }

    public String getValue() {
        return value;
    }

    @Override
    public Stream<String> getNames() {
        return Stream.of(values()).map(GeneticTestingOrderField::getValue);
    }

    @Override
    public boolean check(String fieldName) {
        return OrderField.check(this, fieldName);
    }
}
